<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <title>管理后台</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <!-- 新 Bootstrap 核心 CSS 文件 -->
        <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

        <!-- 可选的Bootstrap主题文件（一般不用引入） -->
        <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

        <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
        <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

        <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
        <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>        
        <link href="Public/admin/css/dashboard.css" rel="stylesheet">
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.1/bootstrap-table.min.css">
    </head>
    <body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">管理后台</a>
        </div>
        <include file="./Public/admin/navbar.html" keywords="1" />

      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
         <div class="col-sm-3 col-md-2">
        <include file="./Public/admin/menu.html" keywords="1" />
         </div>
        <!--正式内容开始-->
        <div class="col-sm-9 col-md-10  main">
            <h1 class="page-header">会员列表</h1>
             <P><a class="btn btn-danger" href="{:U(userAdd)}">添加</a></p>                
            
                <div class="form-group">
                   
<!--                    <div class="col-sm-2">
                         <select class="form-control sex" name="sex">
                              <option value="">选择性别</option>
                              <option value="1">男</option>
                              <option value="2">女</option>
                         </select>
                    </div>-->
                     <div class="col-sm-2">
                         <select class="role_id form-control" name="role_id">
                              <option value="">选择麦主</option>
                              <option value="1">是</option>
                              <option value="0">否</option>
                         </select>
                    </div>  
                    
                     <div class="col-sm-2">
                          <input type="text" name="userid" class="userid form-control" placeholder="用户ID">

                    </div>     
                    
                     <div class="col-sm-2">
                          <input type="text" name="name" class="name form-control" placeholder="呢称">

                    </div>                      
                      <div class="col-sm-2">
                          <button type="submit" onclick="search();" class="btn btn-primary">搜索</button>
                    </div>  
                    </form
                </div>        
            
            <table id="table" ></table> 
        </div>
        <!--正式内容结束-->
      </div>
    </div>
   
        
    <!-- 模态框（Modal）-->
    <div class="modal fade  in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" style="width: 800px; line-height: 25px;">
                            <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                            &times;
                                    </button>
                                    <h4 class="modal-title" id="myModalLabel">
                                            详细信息
                                    </h4>
                            </div>
                            <div class="bodyTb">

                            

                            </div>
                    </div><!-- /.modal-content -->
            </div><!-- /.modal -->
    </div>

    <script src="http://cdn.bootcss.com/bootstrap-table/1.9.1/bootstrap-table.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap-table/1.9.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript">

        $('#table').bootstrapTable({
            url:'./index.php?m=Center&c=Admin&a=userListData',
                dataType: "json",
                silentSort:true,
                pagination:true,
                pageSize:25,
                search:false,
                showExport:true,
                filterControl:true,
                showColumns:true,
                pageList: [10, 25, 50, 100],
                showRefresh: true,                  //是否显示刷新按钮
                clickToSelect: true,                //是否启用点击选中行
                uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
                minimumCountColumns: 2,             //最少允许的列数
                showToggle:true, //是否显示详细视图和列表视图的切换按钮
                cardView: false, //是否显示详细视图
                strictSearch: true,
                
            columns: [{
                field: 'id',
                title: 'id',
                align : 'center',
                valign : 'middle',
                sortable: true
            },  {
                field: 'headimgurl',
                title: '头像',
                align : 'center',
                valign : 'middle',    
                formatter:function(value,row,index){  
                   var a = '<img height="40" src="'+row.headimgurl+'">';                   
                        return a;  
                    } 
            },{
                field: 'name',
                title: '名字',
                align : 'center',
                valign : 'middle'
                
            },{
                field: 'sex',
                title: '性别',
                align : 'center',
                valign : 'middle',
                sortable: true,
                 formatter:function(value,row,index){  
                   var sex = "";
                   if(row.sex == 1){
                        sex = "男";
                   }else{
                        sex = "女";
                   }       
                   return sex;  
                 } 
                
            },{
                field: 'coin',
                title: '金币',
                align : 'center',
                valign : 'middle',
                sortable: true
            },{
                field: 'deposit',
                title: '麦币',
                align : 'center',
                valign : 'middle',
                sortable: true
            },{
                field: 'addtime',
                title: '注册时间',
                align : 'center',
                valign : 'middle',
                sortable: true
            },{
                field: 'logintime',
                title: '登录时间',
                align : 'center',
                valign : 'middle',
                sortable: true
            },{
                field: 'role_id',
                title: '身份',          
                align : 'center',
                valign : 'middle',
                formatter:function(value,row,index){  
                   var role = "";
                   if(row.role_id == 1){
                        role = "麦主";
                   }else{
                        role = "用户";
                   }       
                   return role;  
                 },
                 sortable: true,
                
            },{
                field: 'recommend',
                title: '推荐麦主',          
                align : 'center',
                valign : 'middle',
                formatter:function(value,row,index){  
                   var recommend = "";
                   if(row.recommend == 1){
                        recommend = "是";
                   }else{
                        recommend = "否";
                   }       
                   return recommend;  
                 },
                 sortable: true,
                
            },{
                field: 'option',
                title: '编辑',
                align : 'center',
                valign : 'middle',
                formatter:function(value,row,index){  
                        var but = '<a data-toggle="modal" data-target="#myModal" onclick="userInfo('+JSON.stringify(row).replace(/"/g, '&quot;')+')">详细信息</a>'
                        return but;  
                    } 
            },{
                field: 'option',
                title: '编辑',
                align : 'center',
                valign : 'middle',
                formatter:function(value,row,index){  
                   if(row.locked == "0"){
                     var e = '<a href="./index.php?m=Center&c=Admin&a=lock&edit='+row.id+'&status=1" >'+'冻结</a> ';    
                   }else{
                     var e = '<a href="./index.php?m=Center&c=Admin&a=lock&edit='+row.id+'&status=0" >'+'恢复</a> ';     
                   }
                   
                   var d = '<a href="./index.php?m=Center&c=Admin&a=delete&table=users_mcs&did='+row.id+'">删除</a> '; 
                        return e+d;  
                    } 
            }  
            ]
        });
         
        function search(){
            var sex = $(".sex").val();
            var role_id = $(".role_id").val();
            var name = $(".name").val();
            var userid = $(".userid").val();
            $('#table').bootstrapTable('refresh', {url: '?m=Center&c=admin&a=userListData&role_id='+role_id+'&name='+name+'&userid='+userid+''});
        }
        function userInfo(row){
          console.log(row);
          
          var sex = "";
          if(row.sex == '1'){
              sex = "男";
          }else{
              sex = "女";
          }
          
          var role = "";
          if(row.role_id == "1"){
              role = "麦主";
          }else{
              role = "用户";
          }
           var picHtml = "";
          if(row.pics){
            if(row.pics.length>0){
              var pics = eval("("+row.pics+")");
              if(pics.length > 0){
                  for(var i=0; i<pics.length;i++){
                    picHtml += "<div class=\"col-md-3\">\n";
                    picHtml += "<a target=\"_blank\" href=\""+pics[i]+"\"><img style=\"margin:5px;\" class=\"img-responsive\"  src='"+pics[i]+"' /></a>\n";
                    picHtml += "<\/div>\n";
                  }
              }
            }
          }
          
          var strVar = "";
               strVar += "<div class=\"modal-body\">\n";
               strVar += "	<div class=\"col-md-12\">\n";

               strVar += "		<div class=\"col-md-6\">\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				ID号：\n"
               strVar += "				"+row.id+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				呢称：\n"
               strVar += "				"+row.name+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				性别：\n"
               strVar += "				"+sex+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				注册方式：\n"              
               strVar += "				"+row.platform+"\n"
               strVar += "			<\/div>\n";           
               strVar += "			<div class=\"col-md-12 plr0\">\n";                
               strVar += "				所在城市：\n"
               strVar += "				"+row.city+"\n"
               strVar += "			<\/div>\n";    
                strVar += "			<div class=\"col-md-12 plr0\">\n";              
               strVar += "				用户佘额：\n"
               strVar += "				"+row.deposit+"\n"
               strVar += "			<\/div>\n";           
               strVar += "			<div class=\"col-md-12 plr0\">\n";                   
               strVar += "				发起视频：\n";

               strVar += "				"+row.video_times+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				注册时间：\n"
               strVar += "				"+row.addtime+"\n";
               strVar += "			<\/div>\n";
               strVar += "		<\/div>\n";
               strVar += "		<div class=\"col-md-6\">\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				身份：\n"
               strVar += "				"+role+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				人性签名："
               strVar += "				"+row.introduction+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				兴趣爱好：\n";
               strVar += "				"+row.interest_ids+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				麦主佘额：\n";
               strVar += "				"+row.coin+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 \">\n";
               strVar += "				接听视频：\n"
               strVar += "				"+row.video_times+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0\">\n";
               strVar += "				最近登录：\n"
               strVar += "				"+row.logintime+"\n";
               strVar += "			<\/div>\n";
               
               strVar += "			<div class=\"col-md-12 plr0\">\n";
               strVar += "				手机：\n"
               strVar += "				"+row.mob+"\n";
               strVar += "			<\/div>\n";
               
               strVar += "			<div class=\"col-md-12 plr0\">\n";
               strVar += "				openID：\n"
               strVar += "				"+row.openid+"\n";
               strVar += "			<\/div>\n";
               
               
               strVar += "		<\/div>\n";
               strVar += "	<\/div>\n";
               strVar += "	<div class=\"clearfix\">\n";
               strVar += "	<\/div>\n";
               strVar += "<\/div>\n";
               strVar += "<div class=\"modal-body\">\n";
               strVar += "	<div class=\"col-md-12 plr0 \">\n";
               strVar += "		<div class=\"col-md-2 plr0\">\n";
               strVar += "			<img width='80' src='"+row.headimgurl+"' />\n";
               strVar += "		<\/div>\n";
               strVar += "		<div class=\"col-md-10 plr0\">\n";

               strVar += "				"+picHtml+"\n";

               strVar += "		<\/div>\n";
               strVar += "	<\/div>\n";
               strVar += "<\/div>\n";
               strVar += "<div class=\"clearfix\">\n";
               strVar += "<\/div>\n";
               
               if(row.role_id=="1"){
               strVar += "	<div class=\"modal-header\">	<h4 class=\"modal-title\" id=\"myModalLabel\">\n";
               strVar += "			麦主信息\n";
               strVar += "		<\/h4><\/div>\n";                   
               strVar += "<div class=\"modal-body\">\n";
               strVar += "	<div class=\"col-md-12 \">\n";
               strVar += "		<div class=\"col-md-6\">\n";
               strVar += "			<div class=\"col-md-6 plr0 text-right\">\n";
               strVar += "				认证时间：\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0\">\n";
               strVar += "				"+row.mc_log_time+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0 text-right\">\n";
               strVar += "				真实姓名：\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0\">\n";
               strVar += "				"+row.real_name+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0 text-right\">\n";
               strVar += "				自我介绍：\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0\">\n";
               strVar += "				"+row.mc_introduction+"\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0 text-right\">\n";
               strVar += "				声音类型：\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0\">\n";
               strVar += "				"+row.voice_ids+"\n";
               strVar += "			<\/div>\n";
               strVar += "		<\/div>\n";
               strVar += "		<div class=\"col-md-6\">\n";
               strVar += "			<div class=\"col-md-6 plr0 text-right\">\n";
               strVar += "				\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-6 plr0\">\n";
               strVar += "				审核音频\n";
               strVar += "			<\/div>\n";
               strVar += "			<div class=\"col-md-12 plr0 text-right\">\n";
               
               strVar += "<audio controls>\n";
               strVar += "  <source src=\""+row.audio+"\"  type=\"audio/ogg\">\n";
               strVar += "您的浏览器不支持 audio 元素。\n";
               strVar += "<\/audio>\n";              
               			
               strVar += "			<\/div>\n";

               strVar += "		<\/div>\n";
               strVar += "	<\/div>\n";
               strVar += "	<div class=\"clearfix\">\n";
               strVar += "	<\/div>\n";
               
               }
               strVar += "	<p>\n";
               strVar += "	<\/p>\n";
               strVar += "	<div class=\"col-md-8 col-md-offset-2\">\n";
               strVar += "		<div class=\"col-md-4\">\n";
               strVar += "			改变用户身份\n";
               strVar += "			<select class=\"role_id_select form-control\" name=\"role_id_select\">\n";
               strVar += "				<option value=\"-1\">用户身份<\/option>\n";
               strVar += "				<option value=\"1\">麦主<\/option>\n";
               strVar += "				<option value=\"0\">用户<\/option>\n";
               strVar += "			<\/select>\n";
               strVar += "		<\/div>\n";
               
               strVar += "		<div class=\"col-md-4\">\n";
               strVar += "			推荐麦主\n";
               strVar += "			<select class=\"mz_id form-control\" name=\"mz_id\">\n";
               strVar += "				<option value=\"-1\">推荐麦主<\/option>\n";
               strVar += "				<option value=\"1\">是<\/option>\n";
               strVar += "				<option value=\"0\">否<\/option>\n";
               strVar += "			<\/select>\n";
               strVar += "		<\/div>\n";               
               
               strVar += "		<div class=\"col-md-4\">\n";
               strVar += "			密码 <input type=\"password\" value=\"\" class=\"pwd form-control\" placeholder=\"密码\" name=\"pwd\">\n";
               strVar += "		<\/div>\n";
               strVar += "		<div class=\"clearfix\">\n";
               strVar += "		<\/div>\n";
               strVar += "	<\/div>\n";
               strVar += "	<p>\n";
               strVar += "	<\/p>\n";
               strVar += "<\/div>\n";
               
               strVar += "<div class=\"clearfix\">\n";
               strVar += "<\/div>\n";
               strVar += "<div class=\"modal-footer\">\n";
               strVar += "	<button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">关闭\n";
               strVar += "	<\/button>\n";
               strVar += "	<button type=\"button\" onclick=\"userUpdata("+row.id+")\" class=\"btn btn-primary\">\n";
               strVar += "                                            提交更改\n";
               strVar += "	<\/button>\n";
               strVar += "<\/div>\n";               
               $(".bodyTb").html(strVar);

        }
        
        
        function userUpdata(userid){
          var role_ids = $(".role_id_select").val();
          var pwd = $(".pwd").val();
          var rmz_id = $(".mz_id").val();

          if(role_ids =="-1"){
              alert('请选择身份！');
              return false;
          }
          
          if(rmz_id =="-1"){
              alert('请选择麦主！');
              return false;
          }   
          
          if(pwd ==""){
              alert("请输入密码！");
              return false;
          }
          
          $.ajax({
           url : "index.php?m=Center&c=admin&a=userUpdata",
           type : "POST",
         //  contentType: "application/json;charset=utf-8",
           data :{'userid':userid,'role_id':role_ids,'rmz_id':rmz_id,'pwd':pwd},
           dataType : "json",
           success : function(result) {
               if(result.status == "0"){
                   alert('更新成功！');
               }else{
                   alert(result.data);
               }
           },
           error:function(msg){
             $(".notice").html('Error:'+msg);
          }
         })
          
        }
    </script>
    </body>
</html>
